<?php
	$css_list[0]['url'][] = './tpl/css/article.css';
	$css_list[0]['url'][] = './tpl/css/note.css';
?>
<!--{template inc/header_n}-->

<div class="main_warp">
    <div class="inventory">
        <!--{template inc/list/list_menu}-->

        <div class="i_righter">
            <div class="product_view">
                <div class="i_title">
                    <h3>{$workplan['title']}</h3>
                    <br class="g_clear" />
                    <div class="j_time">
                    时间:<?php echo date('Y-m-d', $workplan['sj']);?>&nbsp;&nbsp;
                    状态:{if $workplan['flag'] == 0}<span style="color:blue;">未审核</span>{elseif $workplan['flag'] == 1}<span style="color:red;">未完成</span>{else}<span style="color:green;">已完成</span>{/if}&nbsp;&nbsp;
                    操作:{if $workplan['flag'] == 0}{if $_FANWE['user']['bossid'] > 0}-{else}<a href="/list.php?action=workplan&op=setflag&flag=1&id={$workplan['id']}&uid={$workplan['uid']}">通过审核</a>{/if}{elseif $workplan['flag'] == 1}<a href="/list.php?action=workplan&op=setflag&flag=2&id={$workplan['id']}&uid={$workplan['uid']}">确认完成</a>{else}{if $_FANWE['user']['bossid'] > 0}-{else}<a href="/list.php?action=workplan&op=setflag&flag=1&id={$workplan['id']}&uid={$workplan['uid']}">尚未完成</a>{/if}{/if}
                    </div>
                </div>

                <div class="i_content">{$workplan['content']}</div>
                
                <div class="note_comment" id="pic-comments">
                    <form method="post">
                        <div class="pub_box" id="publish_note">
                            <div class="pub_edit r5">
                                <div><span class="fw_count">{sprintf char_check 140}</span></div>
                                <div>
                                    <img class="fl pr10 " style="clear: both" src="{avatar $_FANWE['user']['avatar'] m}" height="64">
                                    <textarea id="content" name="content" class="PUB_TXT pub_txt fl rl5" length="140" position="0" style="width:550px;"></textarea>
                                    <input type="button" value="评论" class="pub_btn fl rr5 comment_btn" onclick="$.Add_Workplan_Comment(this, '#SHARE_COMMENT_LIST_{$workplan['id']}')">
                                </div>
                                <div class="pub_ext">
                                    <div class="pub_opt fl">
                                        <span class="fl">{lang add}：</span>
                                        <a w="note" onclick="$.Show_Expression(this)" href="javascript:;" style="background-position: 0pt -3px;" class="add_face">{lang face}</a>
                                    </div>
                                    <div class="pub_out fr">
                                        <input type="hidden" value="$workplan['id']" name="share_id" />
                                        <input type="hidden" name="parent_id" value="0" />
                                        <input type="hidden" name="comment_type" value="note" />
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div id="SHARE_COMMENT_LIST_BOX">
                            <ul id="SHARE_COMMENT_LIST_{$workplan['id']}" class="c_l rb5">
                                <!--{loop $workplan['comments'] $comment}-->
                                <li class="c_f" id="COMMENT_{$comment['comment_id']}">
                                    <!--{getuser $comment['uid'] 0 'm' ',avt'}-->
                                    <div>
                                        <p class="p1">
                                            <a class="rpl fr" href="javascript:;" uname='{$comment['user']['user_name']}' cid="{$comment['comment_id']}" onclick="$.Reply_Workplan_Comment(this);">回复</a>
                                            <!--{getuser $comment['uid'] 1 '' 'uname'}-->
                                            <span>&nbsp;&nbsp;&nbsp;&nbsp;{$comment['time']}</span>
                                        </p>
                                        <p class="p2">{anchor $comment['content']}</p>
                                    </div>
                                </li>
                                <!--{/loop}-->
                            </ul>
                            <div class="pagination clearfix mt20">
                                <!--{subtemplate inc/pages}-->
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
        <br class="g_clear" />
</div>
<!--{template inc/footer}-->
<script type="text/javascript">
jQuery(function(){
	CommentInit();
});

function CommentInit()
{
	$(".note_comment .pagination a").click(function(){
		var page = $(this).attr('page');
		$.Get_Workplan_Comment("{$workplan['id']}",page,'#SHARE_COMMENT_LIST_BOX',CommentInit);
		return false;
	});
}

/*=====================评论文章BEGIN=====================*/
$.Pop_Workplan_Comment = function(share_id)
{
	$.Close_Fav_Box();
	$.weeboxs.close();

	if(!$.Check_Login())
		return false;

	$.weeboxs.open(SITE_PATH+"services/service.php?m=share&a=comment&id="+share_id, {boxid:'COMMENT_BOX',contentType:'ajax',draggable:false,showButton:false,title:LANG.comment_share,width:480});
}

$.Add_Workplan_Comment = function(obj,parentID)
{
	if(!$.Check_Login())
		return false;

	var form = $(obj).parents("form");
	var formobj = form.get(0);

	if($.trim(formobj.content.value)=='')
	{
		alert(LANG.comment_content_require);
		formobj.content.focus();
		return false;
	}

	var query = form.serialize();

	$.ajax({
		url: SITE_PATH+"services/service.php?m=workplan&a=addcomment",
		type: "POST",
		cache:false,
		data:query,
		dataType: "json",
		success: function(result){
			if(result.status == 1)
			{
				formobj.reset();
				if($(parentID).length > 0)
				{
					var item = $(result.html).css({"display":"none"});
					$(parentID).prepend(item);
					item.slideDown("slow");
				}
				$.weeboxs.close();
			}
			else
			{
				alert(result.error);
			}
		}
	});
}

$.Get_Workplan_Comment = function(share_id,page,boxID,fun)
{
	var query = new Object();
	query.page = page;
	query.share_id = share_id;

	$.ajax({
		url: SITE_PATH+"services/service.php?m=workplan&a=comments",
		type: "POST",
		cache:false,
		data:query,
		dataType: "html",
		success: function(html){
			$(boxID).html(html);
			if(fun != null)
				fun.call(this);
		}
	});
}

$.Get_Workplan_Comment_List = function(obj)
{
	var parent = $(obj).parent();
	var cmtList = parent.siblings('.SHARE_COMMENT_LIST_BOX');
	if(cmtList.length > 0)
	{
		cmtList.remove();
		return false;
	}

	var shareID = $(obj).attr('shareID');
	var query = new Object();
	query.id = shareID;

	$.ajax({
		url: SITE_PATH+"services/service.php?m=share&a=listcomment",
		data:query,
		cache:false,
		type: "POST",
		success: function(html){
			parent.after(html);
			parent.siblings('.SHARE_COMMENT_LIST_BOX').show();
			$.Pub_Count_Bind($(".SHARE_COMMENT_LIST_BOX .PUB_TXT").get(0));
		}
	});
}

$.Reply_Workplan_Comment = function(obj)
{
	if(!$.Check_Login())
		return false;

	var userName = $(obj).attr('uname');
	var cid = $(obj).attr('cid');
	var form = $(obj).parents("form").get(0);
	form.content.value = "//@"+ userName +":" + form.content.value;
	form.parent_id.value = cid;
}
/*=====================评论文章END  =====================*/
</script>